package com.wang.pool.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
 * @author: wangning
 * @date: 2024/1/15 15:17
 */
@Data
@ConfigurationProperties(prefix = "custom.threadpool")
@Configuration
public class CustomThreadProperties {

    /**
     * 核心线程池大小
     */
    private int corePoolSize = Runtime.getRuntime().availableProcessors();

    /**
     * 最大线程池大小
     */
    private int maxPoolSize = corePoolSize * 2 + 1;

    /**
     * 线程空闲多久进行回收，单位：s
     */
    private int keepAliveTime = 60;

    /**
     * 缓冲队列大小
     */
    private int queueCapacity = 2000;

    /**
     * <p>
     * 线程名前缀，便于排查问题，
     * 有个前缀作为标识，知道哪些线程是线程池创建的
     * </p>
     */
    private String thread_name_prefix = "async-task-thread-pool-";

}
